package com.diudiutechnology.www.yadiudiu.util.view.item;

import android.content.Context;
import android.content.Intent;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.diudiutechnology.www.yadiudiu.yadiudiu.mine.MyActivity.AllEvaluationActivity;
import com.diudiutechnology.www.yadiudiu.yadiudiu.mine.MyAdapter.TotalEvaluationAdapter;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.BuyACarFragmentModel;
import com.diudiutechnology.www.yadiudiu.R;
import com.diudiutechnology.www.yadiudiu.util.view.ListViewForScrollView;

import java.util.List;

/**
 * Created by Administrator on 2017/8/19.
 */

public class VehicleDetailsLayoutView extends LinearLayout {


    TextView    mTitle;
    TextView   mDesc ;
    TextView all_evaluation;//查看全部
    ImageView mShowImages ;
    LinearLayout   vehicle ;
    LinearLayout   evaluation_layout ;
    ListViewForScrollView release_listview;
    List<BuyACarFragmentModel> buycarlist;
    Context context;
    TotalEvaluationAdapter adapter;
    public VehicleDetailsLayoutView(Context context) {
        super(context);
        this.context=context;
        init();

    }

    public void setData(int pos) {
        if (pos==0){
            vehicle.setVisibility(VISIBLE);
            evaluation_layout.setVisibility(GONE);
            mShowImages.setImageResource(R.mipmap.tiguanl_banner);
            mTitle.setText("2016款 300TSI 1.8T 自动两驱舒适版，工信部综合百公里油耗7.2L/km，车身尺寸4712*1839*1673,180马力7挡双离合，整车质保三年或十万公里，是您理想的中型SUV选择。");
            mDesc.setText("三温区全自动空调系统 主副驾驶座空调系统分区可调，后排乘员亦可独立调节温度与风量；升级空气净化系统，可过滤99%PM2.5颗粒，隔绝外界污染，净享纯净。");
        }else {
            vehicle.setVisibility(GONE);
            evaluation_layout.setVisibility(VISIBLE);
            adapter=new TotalEvaluationAdapter(context);
            release_listview.setAdapter(adapter);


//                buycarlist=new ArrayList<>();
//                buycarlist.clear();
//                BuyACarFragmentModel model=new BuyACarFragmentModel();
//                model.setName("只是想改个名字");
//                model.setStar("2");
//                model.setDistance("");
//                model.setDate("老板服务态度挺好的，洗车也洗得很彻底，里外都收 拾得挺干净的");
//                model.setPraise("2017.05.31");
//                buycarlist.add(model);
//            adapter.addItem(buycarlist);
            all_evaluation.setText(Html.fromHtml("查看全部评价<font color='#FF4537'>(157)</font>"));
            all_evaluation.setOnClickListener(clickListener);

        }
    }
OnClickListener clickListener=new OnClickListener() {
    @Override
    public void onClick(View view) {
       context.startActivity(new Intent(context,AllEvaluationActivity.class));
    }
};
    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.layout_rent_details_housing, this, true);
            mTitle = (TextView) findViewById(R.id.text);
           mDesc = (TextView) findViewById(R.id.text1);
         mShowImages = (ImageView) findViewById(R.id.image);
           vehicle = (LinearLayout) findViewById(R.id.vehicle);
           evaluation_layout = (LinearLayout) findViewById(R.id.evaluation_layout);
        release_listview = (ListViewForScrollView) findViewById(R.id.release_listview);
        all_evaluation = (TextView) findViewById(R.id.all_evaluation);
    }
}

